{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=2764
  Verdict: Accepted
}
{$APPTYPE CONSOLE}
{$R+,S+,Q+,I+,O-}
uses SysUtils;
var n,i,j,k:longint;
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(n);
for i:=0 to 3 do begin
  for j:=0 to 2 do begin
    for k:=0 to 1 do write(((n*4+i)*3+j)*2+k,' ');
  end;
end;
end.